//
//  HYNetHelper.m
//  HYUser
//
//  Created by Alan Wang on 2020/8/6.
//  Copyright © 2020 victor lau. All rights reserved.
//

#import "HYNetHelper.h"
static NSString const * _authToken;
static BOOL  _isLgoined;

@implementation HYNetHelper
+(BOOL)isLogined{
    return _isLgoined;
}
+(void)setLogined:(BOOL)isLgoined{
    _isLgoined = isLgoined;
}
+(NSString*)appid{
    if ([JFEnvironmentManager isPro]) {
      return @"179577b2-949b-46b9-928a-47bdc4b23498";
    }else{
      return @"179577b2-949b-46b9-928a-47bdc4b23498";
    }
}
+(void)setAuthToken:(NSString*)authToken{
    _authToken = authToken;
}

+(void)auth0auth:(NSString*)accessToken appId:(NSString*)appId tfaToken:(NSString*)tfaToken  verifyType:(NSString*)verifyType  callBack:(JFCallBack)callback{
    
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"accessToken"] = accessToken;
    params[@"appId"] = appId;
    params[@"token"] = tfaToken;
    params[@"verifyType"] = verifyType;
    JFRequestVo * request = [self authRequestVo];
    request.path = @"auth0auth";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
    
}

+(void)smsAuthorizationCode:(NSString*)accessToken appId:(NSString*)appId callBack:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"accessToken"] = accessToken;
    params[@"appId"] = appId;
    JFRequestVo * request = [self authRequestVo];
    request.path = @"sms-authorization-code";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}
+(void)currencies:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self currenciesRequestVo];
    request.path = @"";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)wallets:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self userRequestVo];
    request.path = @"wallets";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)walletsMeta:(NSString *)walletsId callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self userRequestVo];
    request.path = [NSString stringWithFormat:@"wallets/%@", walletsId];
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}


+(void)send:(NSString*)asset_symbol amount:(NSString*)amount  wallet_id:(NSString*)wallet_id  to_wallet_id:(NSString*)to_wallet_id to:(NSString *)to tenor:(NSString*)tenor verifyType:(NSString *)verifyType token:(NSString *)token callBack:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"asset_symbol"] = asset_symbol;
    params[@"amount"] = amount;
    params[@"wallet_id"] = wallet_id;
    if (verifyType) {
        params[@"verifyType"] = @(verifyType.integerValue);
    }
    if (token) {
        params[@"token"] = token;
    }
    if (to_wallet_id) {
        params[@"to_wallet_id"] = to_wallet_id;
    }
    if (to) {
        params[@"to"] = to;
    }
    if (tenor) {
        params[@"tenor"] = tenor;
    }
    JFRequestVo * request = [self transfersRequestVo];
    request.path = @"send";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)tenor:(NSString*)asset_symbol from_wallet_id:(NSString*)from_wallet_id to_wallet_id:(NSString*)to_wallet_id amount:(NSString*)amount callBack:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"asset_symbol"] = asset_symbol;
    params[@"amount"] = amount;
    params[@"to_wallet_id"] = to_wallet_id;
    params[@"from_wallet_id"] = from_wallet_id;
    JFRequestVo * request = [self transfersRequestVo];
    request.path = @"send/tenor";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}


+(void)userCryptoAddress:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self userCryptoAddressRequestVo];
    request.path = @"";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)userCryptoAddressDeleteWithId:(NSString*)addId callback:(JFCallBack)callback{
//    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
//    params[@"id"] = addId;
    
    JFRequestVo * request = [self userCryptoAddressRequestVo];
    request.path = addId;
    request.reqParam = nil;
    request.methodtype = MethodType_Delete;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)userCryptoAddressPathcWithId:(NSString*)addId callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"id"] = addId;
    
    JFRequestVo * request = [self userCryptoAddressRequestVo];
    request.path = @"";
    request.reqParam = params;
    request.methodtype = MethodType_Patch;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}


+(void)userCryptoAddress_new:(NSString*)remarks wallet_address:(NSString*)wallet_address currencies_id:(NSString*)currencies_id token:(NSString *)token callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"remarks"]=remarks;
    params[@"wallet_address"]=wallet_address;
    params[@"currencies_id"]=currencies_id;
    params[@"token"]=token;
    params[@"verifyType"]=@(2);
    
    JFRequestVo * request = [self userCryptoAddressRequestVo];
    request.path = @"new";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}


+(void)verifyMobile:(NSString*)mobile countryCode:(NSString*)countryCode  entity:(NSString*)entity callBack:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"mobile"] = mobile;
    params[@"countryCode"] = countryCode;
    params[@"entity"] = entity;
    JFRequestVo * request = [self userRequestVo];
    request.path = @"verify-mobile";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)verifyCode:(NSString*)code entity:(NSString*)entity callBack:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"code"] = code;
    params[@"entity"] = entity;
    JFRequestVo * request = [self userRequestVo];
    request.path = @"verify-mobile/verify-code";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}
+(void)depositMethods:(NSString *)currencyId callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary:@{@"currencyId":currencyId}];
    JFRequestVo * request = [self depositRequestVo];
    request.path = @"methods";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)deposit:(NSString*)amount wallet_id:(NSString*)wallet_id  method_id:(NSString*)method_id country_iso3166:(NSString*)country_iso3166  currency_id:(NSString*)currency_id user_bank_account_id:(NSString *)user_bank_account_id callBack:(JFCallBack)callback{
    
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"amount"]=amount;
    params[@"wallet_id"]=wallet_id;
    params[@"method_id"]=method_id;
    params[@"country_iso3166"]=country_iso3166;
    params[@"currency_id"]=currency_id;
    if (user_bank_account_id) {
       params[@"deposit_method_details"] = @{@"user_bank_account_id":user_bank_account_id};
    }
    
    JFRequestVo * request = [self depositRequestVo];
    request.path = @"";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+ (void)withdarwFiat:(NSString *)amount wallet_id:(NSString*)wallet_id withdraw_method_id:(NSString*)withdraw_method_id currency_id:(NSString*)currency_id data:(NSArray *)data token:(NSString *)token callBack:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"amount"]=amount;
    params[@"wallet_id"]=wallet_id;
    params[@"withdraw_method_id"]=withdraw_method_id;
    params[@"currency_id"]=currency_id;
    params[@"token"]=token;
    if (data) {
        params[@"data"] = data;
    }
    
    JFRequestVo * request = [self withdrawRequestVo];
    request.path = @"fiat";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}


///withdraw/fiat/method
+(void)withdrawFiatMethodWithCurrencyId:(NSString *)currencyId country:(NSString *)country callBack:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary:@{}];
    if (country) {
        params[@"country"]=country;
    }
    if (currencyId) {
        params[@"currencyId"]=currencyId;
    }
    JFRequestVo * request = [self withdrawRequestVo];
    request.path = @"fiat/method";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)bankAccount:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self bankAccountRequestVo];
    request.path = @"";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)bankAccountDeleteWithId:(NSString*)bankid callback:(JFCallBack)callback{
//    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
//    params[@"id"] = bankid;
    JFRequestVo * request = [self bankAccountRequestVo];
    request.path = bankid;
    request.methodtype = MethodType_Delete;
    request.reqParam = nil;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)bankAccountRequirements:(NSString *)countryCode callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary:@{@"countryCode": countryCode}];
    JFRequestVo * request = [self bankAccountRequestVo];
    request.path = @"requirements";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}
+(void)bankAccount_submit:(NSString*)bank_account_requriement_id user_remark:(NSString*)user_remark account_type:(NSString*)account_type  fields:(NSArray<NSDictionary*>*)fields callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"bank_account_requriement_id"] =bank_account_requriement_id;
    params[@"user_remark"] =user_remark;
    params[@"fields"] =fields;
    params[@"account_type"] =account_type;
    
    JFRequestVo * request = [self bankAccountRequestVo];
    request.path = @"submit";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)transactions:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self transactionsRequestVo];
    request.path = @"";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}
+(void)transactionsWithId:(NSString*)idStr callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self transactionsRequestVo];
    request.path = idStr;
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)transactions2:(NSInteger)type page:(NSInteger)page limit:(NSInteger)limit callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary:@{@"page": @(page), @"perPage": @(limit)}];
    JFRequestVo * request = [self transactions2RequestVo];
    request.path = @[@"incoming", @"outgoing", @"exchange", @"transfers"][type];
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)transactions2:(NSString *)transactionId callback:(JFCallBack)callback{
    JFRequestVo * request = [self transactions2RequestVo];
    request.path = transactionId;
    request.isPost = NO;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)exchanges:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self exchangesRequestVo];
    request.path = @"";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)exchangesCCY1:(NSString *)ccy1 ccy1Amount:(NSString *)ccy1Amount ccy1_wallet_id:(NSString *)ccy1_wallet_id ccy2:(NSString *)ccy2 ccy2_wallet_id:(NSString *)ccy2_wallet_id callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary:@{@"ccy1":ccy1, @"ccy1Amount":ccy1Amount, @"ccy1_wallet_id":ccy1_wallet_id, @"ccy2":ccy2, @"ccy2_wallet_id":ccy2_wallet_id}];
    JFRequestVo * request = [self exchangesRequestVo];
    request.path = @"rfq";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)exchangesTrade:(NSString *)tradeId callback:(JFCallBack)callback{
    if (!tradeId) {
        return;
    }
    NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithDictionary:@{@"trade_id":tradeId}];
    JFRequestVo * request = [self exchangesRequestVo];
    request.path = @"rfq/execute";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)token:(JFCallBack)callback{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = @"https://allweather.auth0.com/oauth/";
    request.isDebug = YES;
    request.path = @"token";
    request.isPost = YES;
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"grant_type"]=@"authorization_code";
    params[@"redirect_uri"]=@"https://dev.allweather.io/users/auth";
    params[@"client_id"]=@"r6K4VJale5DenPGdJbUcSt7rymSGLDzr";
    params[@"code_verifier"]=@"Enum09kjnFvdIDTHqmoueSS8VYyAUBpBgiZb3575QCL";
    params[@"code"]=@"-WBR8WHyP06Xg_fv";
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}
+(void)allUsers:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self userRequestVo];
    request.path = @"";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)usersPatch:(NSString*)country_code  mobile:(NSString*)mobile mobile_verification_code:(NSString*)mobile_verification_code callBack:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"country_code"] = country_code;
    params[@"mobile"] = mobile;
    params[@"mobile_verification_code"] = mobile_verification_code;
    
    JFRequestVo * request = [self userRequestVo];
    request.path = @"";
    request.reqParam = params;
    request.methodtype = MethodType_Patch;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}


+(void)get2faCode:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self userRequestVo];
    request.path = @"get2faCode";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)users_2fa:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self userRequestVo];
    request.path = @"2fa";
    request.isPost = NO;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)users_2fa_toggle:(BOOL)enable  verifyType:(NSString*)verifyType token:(NSString*)token callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"token"] = token;
    params[@"verifyType"] = @([verifyType integerValue]);
    params[@"enable"] = @(enable);
    JFRequestVo * request = [self userRequestVo];
    request.path = @"2fa/toggle";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}

+(void)resetPwd:(NSString*)password verifyType:(NSString*)verifyType  token:(NSString*)token callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"token"] = token;
    params[@"password"] =password;
    params[@"verifyType"] =verifyType;
    JFRequestVo * request = [self userRequestVo];
    request.path = @"resetPwd";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}
+(void)users_2fa_verify:(NSString*)key tfaToken:(NSString*)tfaToken callback:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    params[@"key"] = key;
    params[@"tfaToken"] = tfaToken;
    JFRequestVo * request = [self userRequestVo];
    request.path = @"2fa/verify";
    request.isPost = YES;
    request.reqParam = params;
    request.cacheType = CacheType_Net;
    [self requestWithRequestVo:request callBack:callback];
}
//獲取簽署協議
+(void)singedAgreements:(JFCallBack)callback{
    NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
    JFRequestVo * request = [self onboardingRequestVo];
    request.path = @"agreements";
    request.reqParam = params;
    request.cacheType = CacheType_Net;
     request.methodtype = MethodType_Get;
    [self requestWithRequestVo:request callBack:callback];
}

#pragma mark--辅助方法
+(void)requestWithRequestVo:(JFRequestVo*)vo callBack:(JFCallBack)callback{
    [JFNetRequestHelper requestWithRequestVo:vo callBack:callback];
}
+ (JFRequestVo*)authRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"auth"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}
+ (JFRequestVo*)currenciesRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"currencies"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}

+ (JFRequestVo*)userRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"users"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}

+ (JFRequestVo*)transfersRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"transfers"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}
+ (JFRequestVo*)userCryptoAddressRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"user-crypto-address"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}
+ (JFRequestVo*)depositRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"deposit"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}
+ (JFRequestVo*)withdrawRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"withdraw"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}
+ (JFRequestVo*)bankAccountRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"bank-account"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}
+ (JFRequestVo*)transactionsRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"transactions"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}

+ (JFRequestVo*)transactions2RequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"transactions-v2"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}

+ (JFRequestVo*)exchangesRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"exchanges"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}
+ (JFRequestVo*)onboardingRequestVo{
    JFRequestVo * request = [[JFRequestVo alloc] init];
    request.baseUri = [JFEnvironmentManager getUrlByKey:@"onboarding"];
    request.isDebug = YES;
    [self setHeader:request];
    request.dataparserServiceName = @"HYNetHelper";
    return request;
}
+(void)setHeader:(JFRequestVo*)request{
    NSMutableDictionary * dict = [[NSMutableDictionary alloc] init];
    NSString * authToken = [NSString stringWithFormat:@"Bearer %@",_authToken];
    dict[@"authorization"] = authToken;
    request.header =dict;
}

+(JFResultVo*)dataParser:(id)data  dataParserType:(DataParserType)type{
    
    id dataTemp=nil;
    JFResultVo * resustvo=[[JFResultVo alloc] init];
    resustvo.errorNo=0;
    switch (type) {
        case DataParserType_JSON:
        {
            
            if([data isKindOfClass:[NSDictionary class]]){
                NSDictionary * tempDict = (NSDictionary*)data;
                NSInteger  code = [tempDict integerForKey:@"code"];
                resustvo.errorNo = code;
                resustvo.results = tempDict;
            }else if ([data isKindOfClass:[NSData class]]){
                dataTemp = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
                resustvo.results = dataTemp;
            }else if ([data isKindOfClass:[NSArray class]]){
                NSMutableDictionary * tempDict = [[NSMutableDictionary alloc] init];
                resustvo.errorNo = 0;
                tempDict[@"data"] = data;
                resustvo.results = tempDict;
            }
            
            return resustvo;
            
        }
            break;
            
        case DataParserType_XML:
        {
            
            
        }
            break;
        case DataParserType_WebSocket:
        {
            JFResultVo * resustvo=[[JFResultVo alloc] init];
            resustvo.errorNo = 0;
            resustvo.results = data;
            return resustvo;
            
        }
            break;
            
        default:
            break;
    }
    
    return dataTemp;
}
+(NSString*)errorCodeToErrorMsg:(id)code{
   return @"";
}
@end
